<template>
    <div id="app">
        <!-- <router-view class="view" v-if="isRouterAlive"></router-view> -->
        <keep-alive>
            <router-view v-if="isRouterAlive && $route.meta.keepAlive"></router-view>
        </keep-alive>
        <router-view v-if="isRouterAlive && !$route.meta.keepAlive"></router-view>
    </div>
</template>
<script>
    import Vue from 'vue'
    import Element from 'element-ui'
    import 'element-ui/lib/theme-chalk/index.css'
    import '../static/css/style.css'

    Vue.use(Element)
    export default {
        name: 'App',
        // 提供reload方法
        provide: function () {
            return {
                reload: this.reload
            }
        },
        // isRouterAlive控制显示
        data: function () {
            return {
                isRouterAlive: true
            }
        },
        methods: {
            // 刷新方法
            reload: function () {
                this.isRouterAlive = false;
                // 该方法会在dom更新后执行
                this.$nextTick(function () {
                    this.isRouterAlive = true
                })
            }
        }
    }


</script>
<style>
    #app {}
</style>